import request from '@/request/request'

// 从Excel导入会员
export function importMembers(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/api/userCollections/admin/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 下载Excel模板
export function downloadExcelTemplate() {
  return request({
    url: '/api/userCollections/admin/template',
    method: 'get',
    responseType: 'blob'
  })
}

// 新增会员
export function addMember(data) {
  return request({
    url: '/api/userCollections/admin/add',
    method: 'post',
    data
  })
}

// 删除会员
export function deleteMember(id) {
  return request({
    url: `/api/userCollections/admin/${id}`,
    method: 'delete'
  })
}

// 更新会员
export function updateMember(data) {
  return request({
    url: '/api/userCollections/admin/update',
    method: 'put',
    data
  })
}

// 获取会员详情
export function getMemberById(id) {
  return request({
    url: `/api/userCollections/admin/${id}`,
    method: 'get'
  })
}

// 获取会员列表
export function listMembers(params) {
  return request({
    url: '/api/userCollections/admin/list',
    method: 'get',
    params
  })
}
